var id = $.url('id');
var appVue = new Vue({
	el:'#app',
	data:{
		'company.id':session.getSchID(),
		id:id,
		name:'',
		description:''
	},
	methods:{
		submit:function(){
			if(id){
				$.put({
					url:'companys/'+session.getSchID()+'/departments/'+id,
					data:this._data,
					success:function(res){
						if(res.code == 200){
							toastr['info']('操作成功！', '提示信息');
							setTimeout(function(){location.href='list.html'},config.alertTime);
						}else{
							toastr['error'](res.msg, '错误信息');
						}
					}
				});
			} else {
				$.post({
					url:'company/departments',
					data:this._data,
					success:function(res){
						if(res.code == 200){
							toastr['info']('操作成功！', '提示信息');
							setTimeout(function(){location.href='list.html'},config.alertTime);
						}else{
							toastr['error'](res.msg, '错误信息');
						}
					}
				});
			}
		}
	}
});
if(id){
	$.getData({
		url:'companys/'+session.getSchID()+'/departments/'+id,
		success:function(res){
			var o = res.data;
			for(var i in appVue._data){
				if(o[i]) appVue[i] = o[i];
			}
		}
	})
}